package com.person.leetcode.editor.cn;

/**
 * 11.盛最多水的容器
 * 2022-05-05 17:42:03
 **/
public class Sequence_0011_ContainerWithMostWater {
    public static void main(String[] args) {
        Solution solution = new Sequence_0011_ContainerWithMostWater().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        //只想到遍历了 made 遍历超时了

        /**
         * min(x,y)*t
         * 短板起作用
         *
         * @param a
         * @return
         */
        public int maxArea(int[] a) {
            int start = 0,end = a.length-1;
            int max = 0;
            while(start<end){
                int cur = Math.min(a[start], a[end]) * (end - start);
                max = Math.max(cur,max);
                if (a[start]>=a[end]){
                    end --;
                }else{
                    start ++;
                }
            }
            return max;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}
